<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class MaterialRetreatLog extends BaseModel
{
    use HasFactory;
    protected $table = 'material_retreat_log';
    // 允许批量操作的字段
    protected $fillable = [
        'order_id',
        'material_id',
        'employee_user_id',
        'job_type_id',
        'num',
        'retreat_time',
        'created_at',
        'updated_at',
    ];

    public function scopeSearch($query,$params)
    {
        return $query;
    }

    public function order(){
        return $this->hasOne(Order::class,'id','order_id');
    }

    public function employee(){
        return $this->hasOne(Employee::class,'id','user_id');
    }

    public function job_type(){
        return $this->hasOne(JobType::class,'id','job_type_id');
    }

    public function material(){
        return $this->hasOne(Material::class,'id','material_id');
    }
}
